package sctu.edu.java.year2016.team04.baiyunfei.Exercise;

import javafx.print.Printer;

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.swing.Timer;

import java.awt.Toolkit;

/**
 * 闹钟
 * Created by DE on 2016/5/31.
 */
public class AlarmClock {
    private int delay;//延迟时间
    private boolean flag;//是否发出声音

    public AlarmClock(){
        this.delay=delay;
        this.flag=flag;
    }

    public void start(){
        class Printer implements ActionListener{
            @Override
            public void actionPerformed(ActionEvent e){
                SimpleDateFormat format=new SimpleDateFormat("k:m:s");//定义时间格式
                String result = format.format(new Date());//当前时间
                System.out.println("now is :"+result);

                if(flag){
                    Toolkit.getDefaultToolkit().beep();
                }





            }

        }

        new Timer(delay,new Printer()).start();

    }

    public static void main(String[] args) {
    AlarmClock a=new AlarmClock();
    }
}

